************************************************
***Title: heterogeneity_by_pollen_type.do
***Creators: Joelle Abramowitz, Shooshan Danagoulian, and Owen Fleming*
***Notes: This file produces the main estimates stratified by pollen type - total, tree, and grass/weed.

*For questions, contact
*Owen Fleming
*hg3490@wayne.edu
************************************************


**********SETUP
use data/for_analysis, clear


**********PRODUCE ESTIMATES
***Total
*Generate sample
ppmlhdfe count pollen_q2_ls pollen_q3_ls pollen_q4_ls $weather, absorb(county year_month month_day) cluster(county) tolerance(1e-06)
gen sample = e(sample)

*Treatment: location-season quartiles
eststo main_s1: poisson count pollen_q2_ls pollen_q3_ls pollen_q4_ls $weather if sample==1, cluster(county) tolerance(1e-06)
estadd ysumm
estadd scalar counties = e(N_clust)
estadd local Controls "Weather" 
estadd local FE ""

*Treatment: location-season quartiles
eststo main_s2: ppmlhdfe count pollen_q2_ls pollen_q3_ls pollen_q4_ls $weather if sample==1, absorb(county month year) cluster(county) tolerance(1e-06)
estadd ysumm
estadd scalar counties = e(N_clust)
estadd local Controls "Weather" 
estadd local FE "County, Month, Year"

*Treatment: location-season quartiles
eststo main_s3: ppmlhdfe count pollen_q2_ls pollen_q3_ls pollen_q4_ls $weather if sample==1, absorb(county year_month month_day) cluster(county) tolerance(1e-06)
estadd ysumm
estadd scalar counties = e(N_clust)
estadd local Controls "Weather" 
estadd local FE "County, Year x Month, Month x Day"

drop sample


***Tree pollen
*Generate sample
ppmlhdfe count treepollen_q2_ls treepollen_q3_ls treepollen_q4_ls $weather, absorb(county year_month month_day) cluster(county) tolerance(1e-06)
gen sample = e(sample)

*Treatment: location-season quartiles
eststo main_tree_s1: poisson count treepollen_q2_ls treepollen_q3_ls treepollen_q4_ls $weather if sample==1, cluster(county) tolerance(1e-06)
estadd ysumm
estadd scalar counties = e(N_clust)
estadd local Controls "Weather" 
estadd local FE ""

*Treatment: location-season quartiles
eststo main_tree_s2: ppmlhdfe count treepollen_q2_ls treepollen_q3_ls treepollen_q4_ls $weather if sample==1, absorb(county month year) cluster(county) tolerance(1e-06)
estadd ysumm
estadd scalar counties = e(N_clust)
estadd local Controls "Weather" 
estadd local FE "County, Month, Year"

*Treatment: location-season quartiles
eststo main_tree_s3: ppmlhdfe count treepollen_q2_ls treepollen_q3_ls treepollen_q4_ls $weather if sample==1, absorb(county year_month month_day) cluster(county) tolerance(1e-06)
estadd ysumm
estadd scalar counties = e(N_clust)
estadd local Controls "Weather" 
estadd local FE "County, Year x Month, Month x Day"

drop sample


***Grass/weed pollen
*Generate sample
ppmlhdfe count grassweedpollen_q2_ls grassweedpollen_q3_ls grassweedpollen_q4_ls $weather, absorb(county year_month month_day) cluster(county) tolerance(1e-06)
gen sample = e(sample)

*Treatment: location-season quartiles
eststo main_grassweed_s1: poisson count grassweedpollen_q2_ls grassweedpollen_q3_ls grassweedpollen_q4_ls $weather if sample==1, cluster(county) tolerance(1e-06)
estadd ysumm
estadd scalar counties = e(N_clust)
estadd local Controls "Weather" 
estadd local FE ""

*Treatment: location-season quartiles
eststo main_grassweed_s2: ppmlhdfe count grassweedpollen_q2_ls grassweedpollen_q3_ls grassweedpollen_q4_ls $weather if sample==1, absorb(county month year) cluster(county) tolerance(1e-06)
estadd ysumm
estadd scalar counties = e(N_clust)
estadd local Controls "Weather" 
estadd local FE "County, Month, Year"

*Treatment: location-season quartiles
eststo main_grassweed_s3: ppmlhdfe count grassweedpollen_q2_ls grassweedpollen_q3_ls grassweedpollen_q4_ls $weather if sample==1, absorb(county year_month month_day) cluster(county) tolerance(1e-06)
estadd ysumm
estadd scalar counties = e(N_clust)
estadd local Controls "Weather" 
estadd local FE "County, Year x Month, Month x Day"

drop sample


**********EXPORT
estout using results/heterogeneity_by_pollen_type.xls, cells(b(star label(Coef.) fmt(4)) se(par(`"="("'`")""') label(Std. Err.) fmt(4))) stats(ymean N counties Controls FE) starlevels(* 0.1 ** 0.05 *** 0.01) keep(pollen_q2_ls pollen_q3_ls pollen_q4_ls treepollen_q2_ls treepollen_q3_ls treepollen_q4_ls grassweedpollen_q2_ls grassweedpollen_q3_ls grassweedpollen_q4_ls) legend label replace 
eststo clear


